/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

#ifndef JPEGE_DRV_JPEGE_COMM_H
#define JPEGE_DRV_JPEGE_COMM_H

#include <linux/types.h>
#include "dvpp_cmdlist_num_define.h"
#include "dvpp_cmdlist.h"

#define SPLIT_CMDBUF_LEN 419328      // 4M内存除去SQE 16*64大小再拆分成10个,最终取3276*128作为每个cmdbuf的长度
#define ALIGN_LEN 4                  // 每4byte做一次对齐操作
#define CMDLIST_FIX_WRITE 0x1FFFFE

typedef struct {
    uint32_t is_yuv420; // 0：yuv422, 1：yuv420
    uint32_t swap_yuv;
    uint32_t swap_uv;
    uint32_t width_minus1;   // send传入
    uint32_t height_minus1;  // send传入
    uint64_t y_phy_addr;      // 输入图像device地址virt_addr[0]
    uint64_t c_phy_addr;      // 输入图像device地址virt_addr[1]
    uint32_t y_stride;       // send时用户传入width_stride[0]

    uint64_t stream_addr; // 输出地址

    uint8_t y_quant_table[64];
    uint8_t cb_quant_table[64];
    uint8_t cr_quant_table[64];

    uint64_t read_user_addr; // 回读操作的device地址

    uint8_t dc0_bits_table[16];
    uint8_t dc0_val_table[12];
    uint8_t dc1_bits_table[16];
    uint8_t dc1_val_table[12];

    uint8_t ac0_bits_table[16];
    uint8_t ac0_val_table[162];
    uint8_t ac1_bits_table[16];
    uint8_t ac1_val_table[162];
} jpege_config;


void config_jpege_interrupt(struct CmdNode *node, uint32_t isLastNode);
void config_jepge_next_node(struct CmdBuf *cmd_buf, struct CmdNode *node);
void config_jpege_cmdnode(struct CmdNode *node, jpege_config* jpegeConfig);

#endif // JPEGE_DRV_JPEGE_COMM_H